version: '3.1'
services:
  stats-server:
    build: ewm-stats/server
    image: ewm-server-image
    container_name: ewm-server-container
    ports:
      - "9090:9090"
    depends_on:
      - stats-db
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://stats-db:5432/statistic
      - SPRING_DATASOURCE_USERNAME=user
      - SPRING_DATASOURCE_PASSWORD=pass

  stats-db:
    image: postgres:14-alpine
    container_name: stats-db-container
    ports:
      - "6541:5432"
    environment:
      - POSTGRES_DB=statistic
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=pass

  ewm-service:
    build: ewm-main
    image: ewm-main-image
    container_name: ewm-main-container
    ports:
      - "8080:8080"
    depends_on:
      - ewm-db
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://ewm-db:5432/ewm
      - SPRING_DATASOURCE_USERNAME=user
      - SPRING_DATASOURCE_PASSWORD=pass

  ewm-db:
    image: postgres:14-alpine
    container_name: ewm-db-container
    ports:
      - "6542:5432"
    environment:
      - POSTGRES_DB=ewm
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=pass
